<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Arithmetic operators - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">


<link rel="shortcut icon" href="../../../favicon.ico">



<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"c/language/operator_arithmetic","wgTitle":"c/language/operator arithmetic","wgCurRevisionId":79162,"wgArticleId":9564,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo with reason","Todo no example"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"c/language/operator_arithmetic","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:ca03345b1e2c4d90a25d968753a73b92 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-c {line-height: normal;}
.source-c li, .source-c pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for c
 * CSS class: source-c, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.c.source-c .de1, .c.source-c .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.c.source-c  {font-family:monospace;}
.c.source-c .imp {font-weight: bold; color: red;}
.c.source-c li, .c.source-c .li1 {font-weight: normal; vertical-align:top;}
.c.source-c .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.c.source-c .li2 {font-weight: bold; vertical-align:top;}
.c.source-c .kw1 {color: #0000dd;}
.c.source-c .kw2 {color: #0000ff;}
.c.source-c .kw3 {color: #0000dd;}
.c.source-c .kw4 {color: #0000ff;}
.c.source-c .co1 {color: #909090;}
.c.source-c .co2 {color: #339900;}
.c.source-c .coMULTI {color: #ff0000; font-style: italic;}
.c.source-c .es0 {color: #008000; font-weight: bold;}
.c.source-c .es1 {color: #008000; font-weight: bold;}
.c.source-c .es2 {color: #008000; font-weight: bold;}
.c.source-c .es3 {color: #008000; font-weight: bold;}
.c.source-c .es4 {color: #008000; font-weight: bold;}
.c.source-c .es5 {color: #008000; font-weight: bold;}
.c.source-c .br0 {color: #008000;}
.c.source-c .sy0 {color: #008000;}
.c.source-c .sy1 {color: #000080;}
.c.source-c .sy2 {color: #000040;}
.c.source-c .sy3 {color: #000040;}
.c.source-c .sy4 {color: #008080;}
.c.source-c .st0 {color: #008000;}
.c.source-c .nu0 {color: #000080;}
.c.source-c .nu6 {color:#000080;}
.c.source-c .nu8 {color:#000080;}
.c.source-c .nu12 {color:#000080;}
.c.source-c .nu16 {color:#000080;}
.c.source-c .nu17 {color:#000080;}
.c.source-c .nu18 {color:#000080;}
.c.source-c .nu19 {color:#000080;}
.c.source-c .ln-xtra, .c.source-c li.ln-xtra, .c.source-c div.ln-xtra {background-color: #ffc;}
.c.source-c span.xtra { display:block; }

/*]]>*/
</style>
<style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style>
<!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]-->
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-c_language_operator_arithmetic skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        
        <!-- /header -->
        <!-- content -->
        <div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
                <h1 id="firstHeading" class="firstHeading">Arithmetic operators</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../c.html" title="c">c</a>‎ | <a href="../language.1.html" title="c/language">language</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr">
<div class="t-navbar" style="">
<div class="t-navbar-sep"> </div>
<div class="t-navbar-head">
<a href="../../c.html" title="c"> C</a><div class="t-navbar-menu"><div>
<div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.1.html" title="c/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="c/header"> headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../types.html" title="c/types"> Type support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../memory.html" title="c/memory"> Dynamic memory management</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="c/error"> Error handling</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../program.html" title="c/program"> Program utilities</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../variadic.html" title="c/variadic"> Variadic function support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../chrono.html" title="c/chrono"> Date and time utilities</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="c/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="c/algorithm"> Algorithms</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="c/numeric"> Numerics</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="c/io"> Input/output support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="c/locale"> Localization support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="c/thread"> Thread support</a> <span class="t-mark-rev t-since-c11">(C11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="c/atomic"> Atomic operations</a> <span class="t-mark-rev t-since-c11">(C11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../experimental.html" title="c/experimental"><span class="t-lines"><span>Technical Specifications</span></span></a></div></div></td></tr>
</table></div>
<div></div>
</div></div>
</div>
<div class="t-navbar-sep"> </div>
<div class="t-navbar-head">
<a href="../language.1.html" title="c/language"> C language</a><div class="t-navbar-menu"><div>
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ascii.html" title="c/language/ascii"><span class="t-lines"><span>ASCII chart</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="basic_concepts.html" title="c/language/basic concepts">Basic concepts</a>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="translation_phases.html" title="c/language/translation phases"><span class="t-lines"><span>translation phases</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../comment.html" title="c/comment"><span class="t-lines"><span>comment</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="identifier.html" title="c/language/identifier"><span class="t-lines"><span>identifier</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="scope.html" title="c/language/scope"><span class="t-lines"><span>scope</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="lifetime.html" title="c/language/lifetime"><span class="t-lines"><span>lifetime</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="name_space.html" title="c/language/name space"><span class="t-lines"><span>name space</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="compatible_type.html" title="c/language/type"><span class="t-lines"><span>type</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="arithmetic_types.html" title="c/language/arithmetic types"><span class="t-lines"><span>arithmetic types</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="object.html" title="c/language/object"><span class="t-lines"><span>object</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="main_function.html" title="c/language/main function"><span class="t-lines"><span>main function</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="memory_model.html" title="c/language/memory model"><span class="t-lines"><span>memory model</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../keyword.html" title="c/keyword"> Keywords</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../preprocessor.html" title="c/preprocessor"> Preprocessor</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="statements.html" title="c/language/statements"> Statements</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="expressions.html" title="c/language/expressions"> Expressions</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="initialization.html" title="c/language/initialization"> Initialization</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="declarations.html" title="c/language/declarations"> Declarations</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="functions.html" title="c/language/functions"> Functions</a>
</td></tr>
<tr class="t-nv-h2"><td colspan="5"> Miscellaneous</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="history.html" title="c/language/history"><span class="t-lines"><span>history of C</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../experimental.html" title="c/experimental">Technical Specifications</a> </td></tr>
</table></div>
<div></div>
</div></div>
</div>
<div class="t-navbar-sep"> </div>
<div class="t-navbar-head">
<a href="expressions.html" title="c/language/expressions"> Expressions</a><div class="t-navbar-menu"><div>
<div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> General </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="value_category.html" title="c/language/value category"><span class="t-lines"><span>value category</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="eval_order.html" title="c/language/eval order"><span class="t-lines"><span>evaluation order and sequence points</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="constant_expression.html" title="c/language/constant expression"><span class="t-lines"><span>constant expressions</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="conversion.html" title="c/language/conversion"><span class="t-lines"><span>implicit conversions</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="generic.html" title="c/language/generic"><span class="t-lines"><span>generic selection</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="expressions.html#Constants_and_literals" title="c/language/expressions">constants and literals</a> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="integer_constant.html" title="c/language/integer constant"><span class="t-lines"><span>integer constant</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="floating_constant.html" title="c/language/floating constant"><span class="t-lines"><span>floating constant</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="character_constant.html" title="c/language/character constant"><span class="t-lines"><span>character constant</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="string_literal.html" title="c/language/string literal"><span class="t-lines"><span>string literal</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="compound_literal.html" title="c/language/compound literal"><span class="t-lines"><span>compound literal</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div>
</div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="expressions.html#Operators" title="c/language/expressions">operators</a> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_precedence.html" title="c/language/operator precedence"><span class="t-lines"><span>operator precedence</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_member_access.html" title="c/language/operator member access"><span class="t-lines"><span>member access and indirection</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_logical.html" title="c/language/operator logical"><span class="t-lines"><span>logical operators</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_comparison.html" title="c/language/operator comparison"><span class="t-lines"><span>comparison operators</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>arithmetic operators</span></span></strong></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_assignment.html" title="c/language/operator assignment"><span class="t-lines"><span>assignment operators</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_incdec.html" title="c/language/operator incdec"><span class="t-lines"><span>increment and decrement</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_other.html" title="c/language/operator other"><span class="t-lines"><span>function call, comma, conditional operator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="sizeof.html" title="c/language/sizeof"><span class="t-lines"><span>sizeof</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="alignof.html" title="c/language/ Alignof"><span class="t-lines"><span>alignof</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="cast.html" title="c/language/cast"><span class="t-lines"><span>cast operators</span></span></a></div></div></td></tr>
</table></div>
</div>
<div></div>
</div></div>
</div>
<div class="t-navbar-sep"> </div>
</div>
<p>Arithmetic operators apply standard mathematical operations to their operands.
</p>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr>
<td class="mbox-empty-cell"></td>
<td class="mbox-text" style="">This section is incomplete<br>Reason: consider a more general-purpose ToC for this and other tables that cover multiple topics </td>
</tr></table>
<table class="wikitable" style="font-size:85%;">

<tr style="text-align:center">
<th> Operator
</th>
<th> Operator name
</th>
<th> Example
</th>
<th> Result
</th>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">+</span></span></span>
</td>
<td> unary plus
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">+</span>a</span></span>
</td>
<td> the value of <b>a</b> after promotions
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">-</span></span></span>
</td>
<td> unary minus
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">-</span>a</span></span>
</td>
<td> the negative of <b>a</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">+</span></span></span>
</td>
<td> addition
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy2">+</span> b</span></span>
</td>
<td> the addition of <b>a</b> and <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">-</span></span></span>
</td>
<td> subtraction
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy2">-</span> b</span></span>
</td>
<td> the subtraction of <b>b</b> from <b>a</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">*</span></span></span>
</td>
<td> product
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy2">*</span> b</span></span>
</td>
<td> the product of <b>a</b> and <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">/</span></span></span>
</td>
<td> division
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy2">/</span> b</span></span>
</td>
<td> the division of <b>a</b> by <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">%</span></span></span>
</td>
<td> modulo
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy2">%</span> b</span></span>
</td>
<td> the remainder of <b>a</b> divided by <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c">~</span></span>
</td>
<td> bitwise NOT
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">~a</span></span>
</td>
<td> the bitwise NOT of <b>a</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy3">&amp;</span></span></span>
</td>
<td> bitwise AND
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy3">&amp;</span> b</span></span>
</td>
<td> the bitwise AND of <b>a</b> and <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy3">|</span></span></span>
</td>
<td> bitwise OR
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy3">|</span> b</span></span>
</td>
<td> the bitwise OR of <b>a</b> and <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy3">^</span></span></span>
</td>
<td> bitwise XOR
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy3">^</span> b</span></span>
</td>
<td> the bitwise XOR of <b>a</b> and <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy1">&lt;&lt;</span></span></span>
</td>
<td> bitwise left shift
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy1">&lt;&lt;</span> b</span></span>
</td>
<td> <b>a</b> left shifted by <b>b</b>
</td>
</tr>
<tr style="text-align:center">
<td> <span class="t-c"><span class="mw-geshi c source-c"><span class="sy1">&gt;&gt;</span></span></span>
</td>
<td> bitwise right shift
</td>
<td> <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy1">&gt;&gt;</span> b</span></span>
</td>
<td> <b>a</b> right shifted by <b>b</b>
</td>
</tr>
</table>
<table id="toc" class="toc"><tr><td>
<div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1">
<a href="operator_arithmetic.html#Overflows"><span class="tocnumber">1</span> <span class="toctext">Overflows</span></a>
<ul>
<li class="toclevel-2 tocsection-2"><a href="operator_arithmetic.html#Floating-point_environment"><span class="tocnumber">1.1</span> <span class="toctext">Floating-point environment</span></a></li>
<li class="toclevel-2 tocsection-3"><a href="operator_arithmetic.html#Floating-point_contraction"><span class="tocnumber">1.2</span> <span class="toctext">Floating-point contraction</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-4">
<a href="operator_arithmetic.html#Unary_arithmetic"><span class="tocnumber">2</span> <span class="toctext">Unary arithmetic</span></a>
<ul>
<li class="toclevel-2 tocsection-5"><a href="operator_arithmetic.html#Notes"><span class="tocnumber">2.1</span> <span class="toctext">Notes</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-6">
<a href="operator_arithmetic.html#Additive_operators"><span class="tocnumber">3</span> <span class="toctext">Additive operators</span></a>
<ul>
<li class="toclevel-2 tocsection-7"><a href="operator_arithmetic.html#Arithmetic_addition_and_subtraction"><span class="tocnumber">3.1</span> <span class="toctext">Arithmetic addition and subtraction</span></a></li>
<li class="toclevel-2 tocsection-8"><a href="operator_arithmetic.html#Pointer_arithmetic"><span class="tocnumber">3.2</span> <span class="toctext">Pointer arithmetic</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-9">
<a href="operator_arithmetic.html#Multiplicative_operators"><span class="tocnumber">4</span> <span class="toctext">Multiplicative operators</span></a>
<ul>
<li class="toclevel-2 tocsection-10"><a href="operator_arithmetic.html#Multiplication"><span class="tocnumber">4.1</span> <span class="toctext">Multiplication</span></a></li>
<li class="toclevel-2 tocsection-11"><a href="operator_arithmetic.html#Division"><span class="tocnumber">4.2</span> <span class="toctext">Division</span></a></li>
<li class="toclevel-2 tocsection-12"><a href="operator_arithmetic.html#Remainder"><span class="tocnumber">4.3</span> <span class="toctext">Remainder</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-13"><a href="operator_arithmetic.html#Bitwise_logic"><span class="tocnumber">5</span> <span class="toctext">Bitwise logic</span></a></li>
<li class="toclevel-1 tocsection-14"><a href="operator_arithmetic.html#Shift_operators"><span class="tocnumber">6</span> <span class="toctext">Shift operators</span></a></li>
<li class="toclevel-1 tocsection-15"><a href="operator_arithmetic.html#References"><span class="tocnumber">7</span> <span class="toctext">References</span></a></li>
<li class="toclevel-1 tocsection-16"><a href="operator_arithmetic.html#See_Also"><span class="tocnumber">8</span> <span class="toctext">See Also</span></a></li>
<li class="toclevel-1 tocsection-17"><a href="operator_arithmetic.html#See_also_2"><span class="tocnumber">9</span> <span class="toctext">See also</span></a></li>
</ul>
</td></tr></table>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Overflows">edit</a>]</span> <span class="mw-headline" id="Overflows">Overflows</span>
</h3>
<p>Unsigned integer arithmetic is always performed <span class="texhtml" style="white-space: nowrap;">modulo 2<span class="t-su">n<br></span></span> where n is the number of bits in that particular integer. E.g. for <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">int</span></span></span>, adding one to <span class="t-lc"><a href="../types/limits.html" title="c/types/limits">UINT_MAX</a></span> gives <span class="t-c"><span class="mw-geshi c source-c">​<span class="nu0">0</span>​</span></span>, and subtracting one from <span class="t-c"><span class="mw-geshi c source-c">​<span class="nu0">0</span>​</span></span> gives <span class="t-lc"><a href="../types/limits.html" title="c/types/limits">UINT_MAX</a></span>.
</p>
<p>When signed integer arithmetic operation overflows (the result does not fit in the result type), the behavior is undefined: it may wrap around according to the rules of the representation (typically 2's complement), it may trap on some platforms or due to compiler options (e.g. <code>-ftrapv</code> in GCC and Clang), or may be completely <a rel="nofollow" class="external text" href="http%3A//blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html">optimized out by the compiler</a>.
</p>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Floating-point environment">edit</a>]</span> <span class="mw-headline" id="Floating-point_environment">Floating-point environment</span>
</h4>
<p>If <a href="../preprocessor/impl.html" title="c/preprocessor/impl"><tt>
#pragma STDC FENV_ACCESS</tt></a> is set to <code>ON</code>, all floating-point arithmetic operators obey the current floating-point <a href="../numeric/fenv/FE_round.html" title="c/numeric/fenv/FE round">rounding direction</a> and report floating-point arithmetic errors as specified in <a href="../numeric/math/math_errhandling.html" title="c/numeric/math/math errhandling">math_errhandling</a> unless part of a <a href="initialization.html" title="c/language/initialization">static initializer</a> (in which case floating-point exceptions are not raised and the rounding mode is to nearest)
</p>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Floating-point contraction">edit</a>]</span> <span class="mw-headline" id="Floating-point_contraction">Floating-point contraction</span>
</h4>
<p>Unless <a href="../preprocessor/impl.html" title="c/preprocessor/impl"><tt>
#pragma STDC FP_CONTRACT</tt></a> is set to <code>OFF</code>, all floating-point arithmetic may be performed as if the intermediate results have infinite range and precision, that is optimizations that omit rounding errors and floating-point exceptions that would be observed if the expression was evaluated exactly as written. For example, allows the implementation of <span class="t-c"><span class="mw-geshi c source-c"><span class="br0">(</span>x<span class="sy2">*</span>y<span class="br0">)</span> <span class="sy2">+</span> z</span></span> with a single fused multiply-add CPU instruction or optimization of <span class="t-c"><span class="mw-geshi c source-c">a <span class="sy1">=</span> x<span class="sy2">*</span>x<span class="sy2">*</span>x<span class="sy2">*</span>x<span class="sy4">;</span></span></span> as <span class="t-c"><span class="mw-geshi c source-c">tmp <span class="sy1">=</span> x<span class="sy2">*</span>x<span class="sy4">;</span> a <span class="sy1">=</span> tmp<span class="sy2">*</span>tmp</span></span>.
</p>
<p>Unrelated to contracting, intermediate results of floating-point arithmetic may have range and precision that is different from the one indicated by its type, see <span class="t-lc"><a href="../types/limits/FLT_EVAL_METHOD.html" title="c/types/limits/FLT EVAL METHOD">FLT_EVAL_METHOD</a></span>
</p>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Unary arithmetic">edit</a>]</span> <span class="mw-headline" id="Unary_arithmetic">Unary arithmetic</span>
</h3>
<p>The unary arithmetic operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <code><b>+</b></code> <span class="t-spar">expression</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <code><b>-</b></code> <span class="t-spar">expression</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
</table>
<div class="t-li1">
<span class="t-li">1)</span> unary plus (promotion)</div>
<div class="t-li1">
<span class="t-li">2)</span> unary minus (negation)
<p>where 
</p>
<table class="t-par-begin">


<tr class="t-par">
<td> <span class="t-spar">expression</span>
</td>
<td> -
</td>
<td>  expression of any <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic type</a>
</td>
</tr>
</table>
</div>
<p>Both unary plus and unary minus first apply <a href="conversion.html" title="c/language/conversion">integral promotions</a> to their operand, and then
</p>
<ul>
<li> unary plus returns the value after promotion
</li>
<li> unary minus returns the negative of the value after promotion (except that the negative of a NaN is another NaN)
</li>
</ul>
<p>The type of the expression is the type after promotion, and the <a href="value_category.html" title="c/language/value category">value category</a> is non-lvalue.
</p>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Notes">edit</a>]</span> <span class="mw-headline" id="Notes">Notes</span>
</h4>
<p>The unary minus invokes undefined behavior due to signed integer overflow when applied to <span class="t-lc"><a href="../types/limits.html" title="c/types/limits">INT_MIN</a></span>, <span class="t-lc"><a href="../types/limits.html" title="c/types/limits">LONG_MIN</a></span>, or <span class="t-lc"><a href="../types/limits.html" title="c/types/limits">LLONG_MIN</a></span>, on typical (2's complement) platforms.
</p>
<p>In C++, unary operator + can also be used with other built-in types such as arrays and functions, not so in C.
</p>
<div class="t-example">
<div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co2">#include &lt;stdio.h&gt;</span>
<span class="co2">#include &lt;complex.h&gt;</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="kw4">void</span><span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw4">char</span> c <span class="sy1">=</span> <span class="st0">'a'</span><span class="sy4">;</span>
    <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"sizeof char: %zu sizeof int: %zu<span class="es1">\n</span>"</span>, <span class="kw4">sizeof</span> c, <span class="kw4">sizeof</span> <span class="sy2">+</span>c<span class="br0">)</span><span class="sy4">;</span>
 
    <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"-1, where 1 is signed: %d<span class="es1">\n</span>"</span>, <span class="sy2">-</span><span class="nu0">1</span><span class="br0">)</span><span class="sy4">;</span>
    <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"-1, where 1 is unsigned: %u<span class="es1">\n</span>"</span>, <span class="sy2">-</span>1u<span class="br0">)</span><span class="sy4">;</span>
 
    <span class="kw4">double</span> <a href="../numeric/complex/complex.html"><span class="kw743">complex</span></a> z <span class="sy1">=</span> <span class="nu0">1</span> <span class="sy2">+</span> <span class="nu0">2</span><span class="sy2">*</span>I<span class="sy4">;</span>
    <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"-(1+2i) = %.1f%+.1f<span class="es1">\n</span>"</span>, <a href="../numeric/complex/creal.html"><span class="kw754">creal</span></a><span class="br0">(</span><span class="sy2">-</span>z<span class="br0">)</span>, <a href="../numeric/complex/cimag.html"><span class="kw751">cimag</span></a><span class="br0">(</span><span class="sy2">-</span>z<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>Possible output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">sizeof char: 1 sizeof int: 4
-1, where 1 is signed: -1
-1, where 1 is unsigned: 4294967295
-(1+2i) = -1.0-2.0</pre></div></div> 
</div>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Additive operators">edit</a>]</span> <span class="mw-headline" id="Additive_operators">Additive operators</span>
</h3>
<p>The binary additive arithmetic operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>+</b></code> <span class="t-spar">rhs</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>-</b></code> <span class="t-spar">rhs</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
</table>
<div class="t-li1">
<span class="t-li">1)</span> addition: <span class="t-spar">lhs</span> and <span class="t-spar">rhs</span> must be one of the following
<dl><dd><ul>
<li> both have <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic types</a>, including complex and imaginary
</li>
<li> one is a pointer to complete object type, the other has integer type</li>
</ul></dd></dl>
</div>


<div class="t-li1">
<span class="t-li">2)</span> subtraction: <span class="t-spar">lhs</span> and <span class="t-spar">rhs</span> must be one of the following
<dl><dd><ul>
<li> both have <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic types</a>, including complex and imaginary
</li>
<li> <span class="t-spar">lhs</span> has pointer to complete object type, <span class="t-spar">rhs</span> has integer type
</li>
<li> both are pointers to complete objects of <a href="compatible_type.html#Comparible_types" title="c/language/type">compatible</a> types, ignoring qualifiers</li>
</ul></dd></dl>
</div>


<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Arithmetic addition and subtraction">edit</a>]</span> <span class="mw-headline" id="Arithmetic_addition_and_subtraction">Arithmetic addition and subtraction</span>
</h4>
<p>If both operands have <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic types</a>, then
</p>
<ul>
<li> first, <a href="conversion.html#Usual_arithmetic_conversions" title="c/language/conversion">usual arithmetic conversions</a> are performed
</li>
<li> then, the values of the operands after conversions are added or subtracted following the usual rules of mathematics (for subtraction, <span class="t-spar">rhs</span> is subtracted from <span class="t-spar">lhs</span>), except that
</li>
</ul>
<dl><dd>
<ul>
<li> if one operand is NaN, the result is NaN
</li>
<li> infinity minus infinity is NaN and <span class="t-lc"><a href="../numeric/fenv/FE_exceptions.html" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></span> is raised
</li>
<li> infinity plus the negative infinity is NaN and <span class="t-lc"><a href="../numeric/fenv/FE_exceptions.html" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></span> is raised
</li>
</ul>
</dd></dl>
<p>Complex and imaginary addition and subtraction are defined as follows (note the result type is imaginary if both operands are imaginary and complex if one operand is real and the other imaginary, as specified by the usual arithmetic conversions):
</p>
<table class="wikitable" style="text-align:center; font-size:85%; max-width:90em;">

<tr>
<th> + or -
</th>
<th> u
</th>
<th> iv
</th>
<th> u + iv
</th>
</tr>
<tr>
<th> x
</th>
<td> x ± u
</td>
<td> x ± iv
</td>
<td> (x ± u) ± iv
</td>
</tr>
<tr>
<th> iy
</th>
<td> ±u + iy
</td>
<td> i(y ± v)
</td>
<td> ±u + i(y ± v)
</td>
</tr>
<tr>
<th> x + iy
</th>
<td> (x ± u) + iy
</td>
<td> x + i(y ± v)
</td>
<td> (x ± u) + i(y ± v)
</td>
</tr>
</table>
<p><br>
</p>
<div class="t-example">
<div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co1">// work in progress</span>
<span class="co1">// note: take part of the c/language/conversion example</span></pre></div></div>
<p><br> 
</p>
</div>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Pointer arithmetic">edit</a>]</span> <span class="mw-headline" id="Pointer_arithmetic">Pointer arithmetic</span>
</h4>
<ul><li> If the pointer <code>P</code> points at an element of an array with index <code>I</code>, then
</li></ul>
<dl><dd>
<ul>
<li> <span class="t-c"><span class="mw-geshi c source-c">P<span class="sy2">+</span>N</span></span> and <span class="t-c"><span class="mw-geshi c source-c">N<span class="sy2">+</span>P</span></span> are pointers that point at an element of the same array with index <code>I+N</code>
</li>
<li> <span class="t-c"><span class="mw-geshi c source-c">P<span class="sy2">-</span>N</span></span> is a pointer that points at an element of the same array with index {tt|I-N}}
</li>
</ul>
</dd></dl>
<p>The behavior is defined only if both the original pointer and the result pointer are pointing at elements of the same array or one past the end of that array. Note that executing p-1 when p points at the first element of an array is undefined behavior and may fail on some platforms.
</p>
<ul><li> If the pointer <code>P1</code> points at an element of an array with index <code>I</code> (or one past the end) and <code>P2</code> points at an element of the same array with index <code>J</code> (or one past the end), then
</li></ul>
<dl><dd>
<ul><li> <span class="t-c"><span class="mw-geshi c source-c">P1<span class="sy2">-</span>P2</span></span> has the value equal to <span class="t-c"><span class="mw-geshi c source-c">J<span class="sy2">-</span>I</span></span> and the type <span class="t-lc"><a href="../types/ptrdiff_t.html" title="c/types/ptrdiff t">ptrdiff_t</a></span> (which is a signed integer type, typically half as large as the size of the largest object that can be declared)
</li></ul>
</dd></dl>
<p>The behavior is defined only if the result fits in <span class="t-lc"><a href="../types/ptrdiff_t.html" title="c/types/ptrdiff t">ptrdiff_t</a></span>.
</p>
<p>For the purpose of pointer arithmetic, a pointer to an object that is not an element of any array is treated as a pointer to the first element of an array of size 1.
</p>
<div class="t-example">
<div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co1">// work in progress</span>
<span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">4</span>, m <span class="sy1">=</span> <span class="nu0">3</span><span class="sy4">;</span>
<span class="kw4">int</span> a<span class="br0">[</span>n<span class="br0">]</span><span class="br0">[</span>m<span class="br0">]</span><span class="sy4">;</span>     <span class="co1">// VLA of 4 VLAs of 3 ints each</span>
<span class="kw4">int</span> <span class="br0">(</span><span class="sy2">*</span>p<span class="br0">)</span><span class="br0">[</span>m<span class="br0">]</span> <span class="sy1">=</span> a<span class="sy4">;</span> <span class="co1">// p == &amp;a[0] </span>
p <span class="sy1">=</span> p <span class="sy2">+</span> <span class="nu0">1</span><span class="sy4">;</span>       <span class="co1">// p == &amp;a[1] (pointer arithmetic works with VLAs just the same)</span>
<span class="br0">(</span><span class="sy2">*</span>p<span class="br0">)</span><span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">99</span><span class="sy4">;</span>    <span class="co1">// changes a[1][2]</span></pre></div></div>
<p><br> 
</p>
</div>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Multiplicative operators">edit</a>]</span> <span class="mw-headline" id="Multiplicative_operators">Multiplicative operators</span>
</h3>
<p>The binary multiplicative arithmetic operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>*</b></code> <span class="t-spar">rhs</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>/</b></code> <span class="t-spar">rhs</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>%</b></code> <span class="t-spar">rhs</span>
</td>
<td> (3)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
</table>
<div class="t-li1">
<span class="t-li">1)</span> multiplication. <span class="t-spar">lhs</span> and <span class="t-spar">rhs</span> must have <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic types</a>
</div>
<div class="t-li1">
<span class="t-li">2)</span> division. <span class="t-spar">lhs</span> and <span class="t-spar">rhs</span> must have <a href="arithmetic_types.html" title="c/language/arithmetic types">arithmetic types</a>
</div>
<div class="t-li1">
<span class="t-li">3)</span> remainder. <span class="t-spar">lhs</span> and <span class="t-spar">rhs</span> must have <a href="arithmetic_types.html" title="c/language/arithmetic types">integer types</a>
</div>
<ul><li> first, <a href="conversion.html#Usual_arithmetic_conversions" title="c/language/conversion">usual arithmetic conversions</a> are performed. Then...
</li></ul>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Multiplication">edit</a>]</span> <span class="mw-headline" id="Multiplication">Multiplication</span>
</h4>
<p>The binary operator * performs multiplication of its operands (after usual arithmetic conversions) following the usual arithmetic definitions, except that
</p>
<ul>
<li> if one operand is a NaN, the result is a NaN
</li>
<li> multiplication if infinity by zero gives NaN and <span class="t-lc"><a href="../numeric/fenv/FE_exceptions.html" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></span> is raised
</li>
<li> multiplication of infinity by a nonzero gives infinity (even for complex arguments)
</li>
</ul>
<p>Because in C, any <a href="arithmetic_types.html" title="c/language/arithmetic types">complex value</a> with at least one infinite part as an infinity even if its other part is a NaN, the usual arithmetic rules do not apply to complex-complex multiplication. Other combinations of floating operands follow the following table:
</p>
<table class="wikitable" style="text-align:center; font-size:85%; max-width:90em;">

<tr>
<th> *
</th>
<th> u
</th>
<th> iv
</th>
<th> u + iv
</th>
</tr>
<tr>
<th> x
</th>
<td> xu
</td>
<td> i(xv)
</td>
<td> (xu) + i(xv)
</td>
</tr>
<tr>
<th> iy
</th>
<td> i(yu)
</td>
<td> −yv
</td>
<td> (−yv) + i(yu)
</td>
</tr>
<tr>
<th> x + iy
</th>
<td> (xu) + i(yu)
</td>
<td> (−yv) + i(xv)
</td>
<td> <i>special rules</i>
</td>
</tr>
</table>
<p>Besides infinity handling, complex multiplication is not allowed to overflow intermediate results, except when <a href="../preprocessor/impl.html" title="c/preprocessor/impl"><tt>
#pragma STDC CX_LIMITED_RANGE</tt></a> is set to <code>ON</code>, in which case the value may be calculated as if by <span class="texhtml" style="white-space: nowrap;">(x+iy)×(u+iv) = (xu-yv)+i(yu+xv)</span>, as the programmer assumes the responsibility of limiting the range of the operands and dealing with the infinities.
</p>
<p>Despite disallowing undue overflow, complex multiplication may raise spurious floating-point exceptions (otherwise it is prohibitively difficult to implement non-overflowing versions)
</p>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Division">edit</a>]</span> <span class="mw-headline" id="Division">Division</span>
</h4>
<p>The binary operator / divides the first operand by the second (after usual arithmetic conversions) following the usual arithmetics definitions, except that
</p>
<ul>
<li> when the type after usual arithmetic conversions is an integer type, the result is the algebraic quotient (not a fraction), <span class="t-rev-inl t-until-c99"><span>rounded in implementation-defined direction</span> <span><span class="t-mark">(until C99)</span></span></span><span class="t-rev-inl t-since-c99"><span>truncated towards zero</span> <span><span class="t-mark-rev t-since-c99">(since C99)</span></span></span>
</li>
<li> if one operand is a NaN, the result is a NaN
</li>
<li> if the first operand is a complex infinity and the second operand is finite, then the
</li>
</ul>
<p>result of the / operator is a complex infinity
</p>
<ul><li> if the first operand is finite and the second operand is a complex infinity, then the
</li></ul>
<p>result of the / operator is a zero
</p>
<p>Because in C, any <a href="arithmetic_types.html" title="c/language/arithmetic types">complex value</a> with at least one infinite part as an infinity even if its other part is a NaN, the usual arithmetic rules do not apply to complex-complex division. Other combinations of floating operands follow the following table:
</p>
<table class="wikitable" style="text-align:center; font-size:85%; max-width:90em;">

<tr>
<th> /
</th>
<th> u
</th>
<th> iv
</th>
</tr>
<tr>
<th> x
</th>
<td> x/u
</td>
<td> i(−x/v)
</td>
</tr>
<tr>
<th> iy
</th>
<td> i(y/u)
</td>
<td> y/v
</td>
</tr>
<tr>
<th> x + iy
</th>
<td> (x/u) + i(y/u)
</td>
<td> (y/v) + i(−x/v)
</td>
</tr>
</table>
<p>Besides infinity handling, complex division is not allowed to overflow intermediate results, except when <a href="../preprocessor/impl.html" title="c/preprocessor/impl"><tt>
#pragma STDC CX_LIMITED_RANGE</tt></a> is set to <code>ON</code>, in which case the value may be calculated as if by <span class="texhtml" style="white-space: nowrap;">(x+iy)/(u+iv) = [(xu+yv)+i(yu-xv)]/(u<span class="t-su">2<br></span>+v<span class="t-su">2<br></span>)</span>, as the programmer assumes the responsibility of limiting the range of the operands and dealing with the infinities.
</p>
<p>Despite disallowing undue overflow, complex division may raise spurious floating-point exceptions (otherwise it is prohibitively difficult to implement non-overflowing versions)
</p>
<p>If the second operand is zero, the behavior is undefined, except that if the IEEE floating-point arithmetic is supported, and the floating-point division is taking place, then
</p>
<ul>
<li> Dividing a non-zero number by ±0.0 gives the correctly-signed infinity and <span class="t-lc"><a href="../numeric/fenv/FE_exceptions.html" title="c/numeric/fenv/FE exceptions">FE_DIVBYZERO</a></span> is raised
</li>
<li> Dividing 0.0 by 0.0 gives NaN and <span class="t-lc"><a href="../numeric/fenv/FE_exceptions.html" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></span> is raised
</li>
</ul>
<h4>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Remainder">edit</a>]</span> <span class="mw-headline" id="Remainder">Remainder</span>
</h4>
<p>The binary operator % yields the remainder of the division of the first operand by the second (after usual arithmetic conversions).
</p>
<p>The sign of the remainder is defined in such a way that if the quotient <code>a/b</code> is representable in the result type, then <span class="t-c"><span class="mw-geshi c source-c"><span class="br0">(</span>a<span class="sy2">/</span>b<span class="br0">)</span><span class="sy2">*</span>b <span class="sy2">+</span> a<span class="sy2">%</span>b <span class="sy1">==</span> a</span></span>.
</p>
<p>If the second operand is zero, the behavior is undefined.
</p>
<p>If the quotient <code>a/b</code> is not representable in the result type, the behavior of both <code>a/b</code> and <code>a%b</code> is undefined (that means <span class="t-c"><span class="mw-geshi c source-c">INT_MIN<span class="sy2">%-</span><span class="nu0">1</span></span></span> is undefined on 2's complement systems)
</p>
<p>Note: the remainder operator does not work on floating-point types, the library function <span class="t-lc"><a href="../numeric/math/fmod.html" title="c/numeric/math/fmod">fmod</a></span> provides that functionality.
</p>
<div class="t-example">
<div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="c source-c"><pre class="de1"><span class="co2">#include&lt;stdio.h&gt;</span>
<span class="co2">#include &lt;stdio.h&gt;</span>
<span class="co2">#include &lt;complex.h&gt;</span>
<span class="co2">#include &lt;math.h&gt;</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="kw4">void</span><span class="br0">)</span>
<span class="br0">{</span>
 
 
<span class="co1">// TODO simpler cases, take some from C++</span>
 
 
   <span class="kw4">double</span> <a href="../numeric/complex/complex.html"><span class="kw743">complex</span></a> z <span class="sy1">=</span> <span class="br0">(</span><span class="nu0">1</span> <span class="sy2">+</span> <span class="nu0">0</span><span class="sy2">*</span>I<span class="br0">)</span> <span class="sy2">*</span> <span class="br0">(</span>INFINITY <span class="sy2">+</span> I<span class="sy2">*</span>INFINITY<span class="br0">)</span><span class="sy4">;</span>
<span class="co1">// textbook formula would give</span>
<span class="co1">// (1+i0)(∞+i∞) ⇒ (1×∞ – 0×∞) + i(0×∞+1×∞) ⇒ NaN + I*NaN</span>
<span class="co1">// but C gives a complex infinity</span>
   <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"%f + i*%f<span class="es1">\n</span>"</span>, <a href="../numeric/complex/creal.html"><span class="kw754">creal</span></a><span class="br0">(</span>z<span class="br0">)</span>, <a href="../numeric/complex/cimag.html"><span class="kw751">cimag</span></a><span class="br0">(</span>z<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
 
<span class="co1">// textbook formula would give</span>
<span class="co1">// cexp(∞+iNaN) ⇒ exp(∞)×(cis(NaN)) ⇒ NaN + I*NaN</span>
<span class="co1">// but C gives  ±∞+i*nan</span>
   <span class="kw4">double</span> <a href="../numeric/complex/complex.html"><span class="kw743">complex</span></a> y <span class="sy1">=</span> <a href="../numeric/complex/cexp.html"><span class="kw769">cexp</span></a><span class="br0">(</span>INFINITY <span class="sy2">+</span> I<span class="sy2">*</span>NAN<span class="br0">)</span><span class="sy4">;</span>
   <a href="../io/fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">"%f + i*%f<span class="es1">\n</span>"</span>, <a href="../numeric/complex/creal.html"><span class="kw754">creal</span></a><span class="br0">(</span>y<span class="br0">)</span>, <a href="../numeric/complex/cimag.html"><span class="kw751">cimag</span></a><span class="br0">(</span>y<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
 
<span class="br0">}</span></pre></div></div>
<p>Possible output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">inf + i*inf 
inf + i*nan</pre></div></div> 
</div>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Bitwise logic">edit</a>]</span> <span class="mw-headline" id="Bitwise_logic">Bitwise logic</span>
</h3>
<p>The bitwise arithmetic operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <code><b>~</b></code> <span class="t-spar">rhs</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>&amp;</b></code> <span class="t-spar">rhs</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>|</b></code> <span class="t-spar">rhs</span>
</td>
<td> (3)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>^</b></code> <span class="t-spar">rhs</span>
</td>
<td> (4)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
</table>
<div class="t-li1">
<span class="t-li">1)</span> bitwise NOT</div>
<div class="t-li1">
<span class="t-li">2)</span> bitwise AND</div>
<div class="t-li1">
<span class="t-li">3)</span> bitwise OR</div>
<div class="t-li1">
<span class="t-li">4)</span> bitwise XOR
<p>where
</p>
<table class="t-par-begin">


<tr class="t-par">
<td>  <span class="t-spar">lhs</span>, <span class="t-spar">rhs</span>
</td>
<td> -
</td>
<td>  expressions of integer type
</td>
</tr>
</table>
</div>
<p>First, operators &amp;, ^, and | perform <a href="conversion.html#Usual_arithmetic_conversions" title="c/language/conversion">usual arithmetic conversions</a> on both operands and the operator ~ performs <a href="conversion.html#Integer_promotions" title="c/language/conversion">integer promotions</a> on its only operand.
</p>
<p>Then, the corresponding binary logic operators are applied bitwise; that is, each bit of the result is set or cleared according to the logic operation (NOT, AND, OR, or XOR), applied to the corresponding bits of the operands.
</p>
<p>Note: bitwise operators are commonly used to manipulate bit sets and bit masks.
</p>
<p>Note: for unsigned types (after promotion), the expression ~E is equivalent to the maximum value representable by the result type minus the original value of E.
</p>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr>
<td class="mbox-empty-cell"></td>
<td class="mbox-text" style="">This section is incomplete<br>Reason: no example </td>
</tr></table>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Shift operators">edit</a>]</span> <span class="mw-headline" id="Shift_operators">Shift operators</span>
</h3>
<p>The bitwise shift operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>&lt;&lt;</b></code> <span class="t-spar">rhs</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
<tr class="t-sdsc">
<td> <span class="t-spar">lhs</span> <code><b>&gt;&gt;</b></code> <span class="t-spar">rhs</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td>
</tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td>
</tr>
</table>
<div class="t-li1">
<span class="t-li">1)</span> left shift of <span class="t-spar">lhs</span> by <span class="t-spar">rhs</span> bits</div>
<div class="t-li1">
<span class="t-li">2)</span> right shift of <span class="t-spar">lhs</span> by <span class="t-spar">rhs</span> bits
<p>where
</p>
<table class="t-par-begin">


<tr class="t-par">
<td>  <span class="t-spar">lhs</span>, <span class="t-spar">rhs</span>
</td>
<td> -
</td>
<td>  expressions of integer type
</td>
</tr>
</table>
</div>
<p>First, <a href="conversion.html" title="c/language/conversion">integer promotions</a> are performed, individually, on each operand (Note: this is unlike other binary arithmetic operators, which all perform usual arithmetic conversions). The type of the result is the type of <span class="t-spar">lhs</span> after promotion. 
</p>
<p>For unsigned <span class="t-spar">lhs</span>, the value of <code>LHS &lt;&lt; RHS</code> is the value of <span class="texhtml" style="white-space: nowrap;">LHS * 2<span class="t-su">RHS<br></span></span>, reduced modulo maximum value of the return type plus 1 (that is, bitwise left shift is performed and the bits that get shifted out of the destination type are discarded). For signed <span class="t-spar">lhs</span>, the value of <code>LHS &lt;&lt; RHS</code> is <span class="texhtml" style="white-space: nowrap;">LHS * 2<span class="t-su">RHS<br></span></span> if it is representable in the promoted type of <span class="t-spar">lhs</span>, otherwise the behavior is undefined.
</p>
<p>For unsigned <span class="t-spar">lhs</span> and for signed <span class="t-spar">lhs</span> with nonnegative values, the value of <code>LHS &gt;&gt; RHS</code> is the integer part of <span class="texhtml" style="white-space: nowrap;">LHS / 2<span class="t-su">RHS<br></span></span>. For negative <code>LHS</code>, the value of <code>LHS &gt;&gt; RHS</code> is implementation-defined (in most implementations, this performs arithmetic right shift, so that the result remains negative)
</p>
<p>In any case, the behavior is undefined if <span class="t-spar">rhs</span> is negative or is greater or equal the number of bits in the promoted <span class="t-spar">lhs</span>.
</p>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr>
<td class="mbox-empty-cell"></td>
<td class="mbox-text" style="">This section is incomplete<br>Reason: no example </td>
</tr></table>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: References">edit</a>]</span> <span class="mw-headline" id="References">References</span>
</h3>
<div class="t-ref-std-11">
<ul><li> C11 standard (ISO/IEC 9899:2011): 
</li></ul>
<dl><dd>
<ul><li> 6.5.3.3 Unary arithmetic operators (p: 89)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.5 Multiplicative operators (p: 92)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.6 Additive operators (p: 92-94)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.7 Bitwise shift operators (p: 94-95)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.10 Bitwise AND operator (p: 97)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.11 Bitwise exclusive OR operator (p: 98)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.12 Bitwise inclusive OR operator (p: 98)
</li></ul>
</dd></dl>
<div class="t-ref-std-c99">
<ul><li> C99 standard (ISO/IEC 9899:1999): 
</li></ul>
<dl><dd>
<ul><li> 6.5.3.3 Unary arithmetic operators (p: 79)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.5 Multiplicative operators (p: 82)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.6 Additive operators (p: 82-84)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.7 Bitwise shift operators (p: 84-85)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.10 Bitwise AND operator (p: 87)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.11 Bitwise exclusive OR operator (p: 88)
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 6.5.12 Bitwise inclusive OR operator (p: 88)
</li></ul>
</dd></dl>
<div class="t-ref-std-c89">
<ul><li> C89/C90 standard (ISO/IEC 9899:1990): 
</li></ul>
<dl><dd>
<ul><li> 3.3.3.3 Unary arithmetic operators 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.5 Multiplicative operators 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.6 Additive operators 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.7 Bitwise shift operators 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.10 Bitwise AND operator 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.11 Bitwise exclusive OR operator 
</li></ul>
</dd></dl>
<dl><dd>
<ul><li> 3.3.12 Bitwise inclusive OR operator 
</li></ul>
</dd></dl>
</div>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: See Also">edit</a>]</span> <span class="mw-headline" id="See_Also">See Also</span>
</h3>
<p><a href="operator_precedence.html" title="c/language/operator precedence"> Operator precedence</a>
</p>
<table class="wikitable">

<tr style="text-align:center">
<th colspan="7"> Common operators
</th>
</tr>
<tr style="text-align:center">
<td> <a href="operator_assignment.html" title="c/language/operator assignment"> assignment</a>
</td>
<td> <a href="operator_incdec.html" title="c/language/operator incdec"> increment<br>decrement</a>
</td>
<td> <strong class="selflink"> arithmetic</strong>
</td>
<td> <a href="operator_logical.html" title="c/language/operator logical"> logical</a>
</td>
<td> <a href="operator_comparison.html" title="c/language/operator comparison"> comparison</a>
</td>
<td> <a href="operator_member_access.html" title="c/language/operator member access"> member<br>access</a>
</td>
<td> <a href="operator_other.html" title="c/language/operator other"> other</a>
</td>
</tr>
<tr style="text-align:center">
<td>
<p><span class="t-c"><span class="mw-geshi c source-c">a <span class="sy1">=</span> b<br>
a <span class="sy2">+</span><span class="sy1">=</span> b<br>
a <span class="sy2">-</span><span class="sy1">=</span> b<br>
a <span class="sy2">*</span><span class="sy1">=</span> b<br>
a <span class="sy2">/</span><span class="sy1">=</span> b<br>
a <span class="sy2">%</span><span class="sy1">=</span> b<br>
a <span class="sy3">&amp;</span><span class="sy1">=</span> b<br>
a <span class="sy3">|</span><span class="sy1">=</span> b<br>
a <span class="sy3">^</span><span class="sy1">=</span> b<br>
a <span class="sy1">&lt;&lt;=</span> b<br>
a <span class="sy1">&gt;&gt;=</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">++</span>a<br>
<span class="sy2">--</span>a<br>
a<span class="sy2">++</span><br>
a<span class="sy2">--</span></span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">+</span>a<br>
<span class="sy2">-</span>a<br>
a <span class="sy2">+</span> b<br>
a <span class="sy2">-</span> b<br>
a <span class="sy2">*</span> b<br>
a <span class="sy2">/</span> b<br>
a <span class="sy2">%</span> b<br>
~a<br>
a <span class="sy3">&amp;</span> b<br>
a <span class="sy3">|</span> b<br>
a <span class="sy3">^</span> b<br>
a <span class="sy1">&lt;&lt;</span> b<br>
a <span class="sy1">&gt;&gt;</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c"><span class="sy3">!</span>a<br>
a <span class="sy3">&amp;&amp;</span> b<br>
a <span class="sy3">||</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c">a <span class="sy1">==</span> b<br>
a <span class="sy3">!</span><span class="sy1">=</span> b<br>
a <span class="sy1">&lt;</span> b<br>
a <span class="sy1">&gt;</span> b<br>
a <span class="sy1">&lt;=</span> b<br>
a <span class="sy1">&gt;=</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c">a<span class="br0">[</span>b<span class="br0">]</span><br>
<span class="sy2">*</span>a<br>
<span class="sy3">&amp;</span>a<br>
a<span class="sy2">-</span><span class="sy1">&gt;</span>b<br>
a.<span class="me1">b</span></span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi c source-c">a<span class="br0">(</span>...<span class="br0">)</span><br>
a, b<br>
<span class="br0">(</span>type<span class="br0">)</span> a<br>
<span class="sy4">?</span> <span class="sy4">:</span><br>
<span class="kw4">sizeof</span><br>
_Alignof</span></span> <span class="t-mark-rev t-since-c11">(since C11)</span>
</p>
</td>
</tr>
</table>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: See also">edit</a>]</span> <span class="mw-headline" id="See_also_2">See also</span>
</h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td colspan="2"> <div class="t-dsc-see">
<span><a href="../../cpp/language/operator_arithmetic.html" title="cpp/language/operator arithmetic">C++ documentation</a></span> for <span class="t-dsc-see-tt"><span>Arithmetic operators</span></span>
</div>
</td>
</tr>

</table>
</div>
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 6770/1000000
Preprocessor generated node count: 13268/1000000
Post‐expand include size: 99325/2097152 bytes
Template argument size: 22017/2097152 bytes
Highest expansion depth: 19/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:9564-0!*!0!!en!*!* and timestamp 20150626104816 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="http%3A//en.cppreference.com/mwiki/index.php">http://en.cppreference.com/mwiki/index.php?title=c/language/operator_arithmetic&amp;oldid=79162</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <div id="catlinks" class="catlinks"><div id="mw-normal-catlinks" class="mw-normal-catlinks">
<a href="http%3A//en.cppreference.com/w/Special%3ACategories" title="Special:Categories">Categories</a>: <ul>
<li><a href="http%3A//en.cppreference.com/w/Category%3ATodo_with_reason" title="Category:Todo with reason">Todo with reason</a></li>
<li><a href="http%3A//en.cppreference.com/w/Category%3ATodo_no_example" title="Category:Todo no example">Todo no example</a></li>
</ul>
</div></div>                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.090 secs. -->
	</body>
<!-- Cached 20150626105023 -->
</html>
